<template>
 <div class="comment-wrapper">
    <div class="items">
      <div class="item" v-for="(item,index) in commentList" :key="'comment'+index">
        <div class="left">
          <img :src="item.user.avatarUrl" alt="用户头像">
        </div>
        <div class="right">
          <div class="top">
            <span class='user'>{{item.user.nickname}}: </span>
            <span class='content'>{{item.content}}</span>
          </div>
          <div class="bottom">
            <div class="time">{{item.timeStr}}</div>
            <div class="like-wrapper">
                <span>👍</span>({{item.likedCount}})
            </div>
          </div>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
import axios from 'axios';
export default {
  data() {
    return {
      commentList: [],
    };
  },
  async created(){
    // 获取id
    const id = this.$route.params.id;
    // 根据id获取热门评论
    
    const res = await axios(`https://autumnfish.cn/comment/hot?id=${id}&type=0`);
    this.commentList = res.data.hotComments;
    console.log(this.commentList);
    
    
  }
};
</script>

<style>
@import url("../assets/css/comment.css");
</style>